<template>
  <div class="appAlarm">
    <div class="mains_contain">
      <div class="contant">

        <el-table :data="tableData" style="width: 100%" fit :max-height="maxHeight" border  size="mini" highlight-current-row :header-cell-style="{ background: '#e5e5e5', color: '#000' }">
          <el-table-column prop="level" label="级别" >

            <template slot-scope="{row}">
              <div class="jbIcon" v-if="row.level == 'Critical'">
                <svg-icon icon-class="jb4" />
                <span style="color:#d81e06">致命</span>
              </div>
              <div class="jbIcon" v-if="row.level == 'Major'">
                <svg-icon icon-class="jb3" />
                <span style="color:#FB8B16">严重</span>
              </div>
              <div class="jbIcon" v-if="row.level == 'Minor'">
                <svg-icon icon-class="jb2" />
                <span style="color:#f4ea2a">次要</span>
              </div>
              <div class="jbIcon" v-if="row.level == 'Warning'">
                <svg-icon icon-class="jb1" />
                <span style="color:#1296db">警告</span>
              </div>
            </template>
          </el-table-column>
          <el-table-column prop="name" label="告警名称" />
          <el-table-column prop="nodeId" label="设备标识" />
          <!-- <el-table-column prop="type" label="告警类型" /> -->
          <el-table-column prop="number" label="告警次数" />
          <el-table-column prop="createTime" label="上报时间">
            <template slot-scope="{ row }">
              {{ row.createTime |formatTime }}
            </template>
          </el-table-column>
          <el-table-column prop="locateInformation" label="定位信息">
          </el-table-column>
          <el-table-column prop="reason" label="附加信息">
            <template slot-scope="{ row }">
              <span v-if="row.reason && row.reason.length > 30">
                <el-popover placement="top-start" title="" max-width="300" trigger="hover">
                  <div>{{ row.reason }}</div>
                  <span slot="reference">
                    {{ row.reason.substr(0,30) + '...' }}
                  </span>
                </el-popover>
              </span>
              <span v-else>{{ row.reason }}</span>
            </template>
          </el-table-column>
          <!-- <el-table-column label="操作" width="350" align="center">
            <template slot-scope="{row}">
              <el-button type="text" size="mini" @click="handleInfo(row)" icon='el-icon-view'>详情</el-button>
              <el-button type="text" size="mini" @click="handleEdit(row)" icon='el-icon-edit' v-has="['groupList:edit']">编辑</el-button>
              <el-button type="text" style="color:#F56C6C" size="mini" @click="onDel(row)" icon='el-icon-delete' v-has="['groupList:delete']">删除</el-button>
            </template>
          </el-table-column> -->
        </el-table>
        <!-- <div style="text-align:right">
          <pagination v-show="pagination.total>0" :limit.sync="pagination.pageSize" :page.sync="pagination.page" :total="pagination.total" @pagination="getPageList" />
        </div> -->
      </div>
    </div>
  </div>
</template>

<script>
import * as api from '@/api/link/deviceGroup'
import * as tenantApi from "@/api/sys/tenant";
// import { account } from "@/utils/validate"
import * as alarmApi from "@/api/link/device";

export default {
  comments: {},
  props: {},
  data() {
    return {
      tableData: []
    }
  },
  computed: {
    maxHeight() {
      var curHeight =
        window.innerHeight ||
        document.documentElement.clientHeight ||
        document.body.clientHeight
      return curHeight - 280
    }
  },
  created() {

    this.getInit()

  },
  mounted() {

  },

  methods: {
    getPageList() { },
    getInit() {
      alarmApi.appAlarm(this.$route.query.nodeId).then(res => {
        console.log(res);
        if (res.code == '200') {
          this.tableData = res.data
        }
      })
    },
  },
}
</script>

<style scoped lang="scss">
.appAlarm {
  padding: 20px;

  .curHeader {
    position: relative;
    // height: 40px;
    .searcherBox {
      position: absolute;
      right: 0;
      top: 0;
    }
  }
  .jbIcon {
    display: flex;
    align-items: center;
    .svg-icon {
      font-size: 24px;
      margin-right: 15px;
    }
  }
  .el-table__header > th {
    padding: 0 !important;
  }
}
</style>
